package org.stvd.service.common.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.stvd.common.utils.ServiceResult;
import org.stvd.core.util.StringUtil;
import org.stvd.entities.common.AffixInfo;
import org.stvd.repository.common.AffixInfoDao;
import org.stvd.service.base.impl.BaseServiceImpl;
import org.stvd.service.common.AffixInfoService;

/**
 * 附件映射Service实现类
 * @author houzx
 */
@Service("affixInfoService")
public class AffixInfoServiceImpl extends BaseServiceImpl<AffixInfo> implements AffixInfoService{

    @Resource(name = "AffixInfoDao")
    private AffixInfoDao affixInfoDao;
    
    @Override
    public List<AffixInfo> listAffixInfo(String infoType, String infoTable, String infoId) {
        if(StringUtil.isEmpty(infoType) && StringUtil.isEmpty(infoTable) && StringUtil.isEmpty(infoId)) {
            return null;
        }
        return affixInfoDao.listAffixInfo(infoType, infoTable, infoId);
    }
    
    @Override
    public ServiceResult<Map<String, Object>> deleteAffixInfo(String infoType, String infoTable, String infoId) {
        ServiceResult<Map<String, Object>> serviceResult = new  ServiceResult<>();
        if(StringUtil.isEmpty(infoType) && StringUtil.isEmpty(infoTable) && StringUtil.isEmpty(infoId)) {
            serviceResult.setParamError("必须指定任一参数值");
            return serviceResult;
        }
        int deleteCount = affixInfoDao.deleteAffixInfo(infoType, infoTable, infoId);
        serviceResult.setMessage("操作成功,删除附件信息"+deleteCount+"条！");
        return serviceResult;
    }

}
